Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

288
Visualizações
how to fix the "Component definition is missing display name" error?
    const IndeterminateCheckbox = React.forwardRef(
  
    ({indeterminate, ...rest}, ref) => {
      const defaultRef = React.useRef();
      const resolvedRef = ref || defaultRef;

      React.useEffect(() => {
        resolvedRef.current.indeterminate = indeterminate;
      }, [resolvedRef, indeterminate]);

      return <input type="checkbox" ref={resolvedRef} {...rest} />;
    },
);

How to fix "Component definition is missing display name" in line 1

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

To fix this error, you should put a displayName on your component. This happens because your arrow function inside forwardRef doesn't have the context of your function name.

Solution one:

Put this on the final of your file.

    const IndeterminateCheckbox = React.forwardRef(
     ({indeterminate, ...rest}, ref) => {
      const defaultRef = React.useRef();
      const resolvedRef = ref || defaultRef;

      React.useEffect(() => {
        resolvedRef.current.indeterminate = indeterminate;
      }, [resolvedRef, indeterminate]);

      return <input type="checkbox" ref={resolvedRef} {...rest} />;
    },
);

IndeterminateCheckbox.displayName = 'IndeterminateCheckbox'

OR

You can avoid use arrow function inside forwardRef and use named functions.

    const IndeterminateCheckbox = React.forwardRef(
     function Component({indeterminate, ...rest}, ref) {
      const defaultRef = React.useRef();
      const resolvedRef = ref || defaultRef;

      React.useEffect(() => {
        resolvedRef.current.indeterminate = indeterminate;
      }, [resolvedRef, indeterminate]);

      return <input type="checkbox" ref={resolvedRef} {...rest} />;
    }
  },
);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda